package com.yupi.project.service.impl;




import kong.unirest.HttpResponse;
import kong.unirest.Unirest;
import org.springframework.stereotype.Service;

@Service
public class DeepSeekAIClient {

    public void DeepSeekAIClient(String question) {
        // 设置超时时间
        Unirest.config()
                .connectTimeout(5000)  // 连接超时时间（毫秒）
                .socketTimeout(30000); // 读取超时时间（毫秒）

        HttpResponse<String> response = Unirest.post("https://api.siliconflow.cn/v1/chat/completions")
                .header("Authorization", "Bearer "+"sk-wiwgclkxeidkeeypicodjtyykmjtcymiaqrdjsmfxalpmlmb")
                .header("Content-Type", "application/json")
                .body("{\n  \"model\": \"deepseek-ai/DeepSeek-V3\"," +
                        "\n  \"messages\": [\n    {\n      \"role\": \"user\"," +
                        "\n      \"content\": \""+question+"\"\n    }\n  ]," +
                        "\n  \"stream\": false,\n  \"max_tokens\": 512," +
                        "\n  \"stop\": [\n    \"null\"\n  ]," +
                        "\n  \"temperature\": 0.7,\n  \"top_p\": 0.7," +
                        "\n  \"top_k\": 50,\n  \"frequency_penalty\": 0.5,\n  \"n\": 1,\n  \"response_format\": {\n    \"type\": \"text\"\n  },\n  \"tools\": [\n    {\n      \"type\": \"function\",\n      \"function\": {\n        \"description\": \"<string>\",\n        \"name\": \"<string>\",\n        \"parameters\": {},\n        \"strict\": false\n      }\n    }\n  ]\n}")
                .asString();
        System.out.println("Status Code: " + response.getStatus());
        System.out.println("Response Body: " + response.getBody());
    }
}
